#import "ALPopoverBackgroundView.h"


#pragma mark Constants
static const CGFloat kALPopoverBackgroundCornerRadius = 3.0f;


#pragma mark -
#pragma mark Class globals
static NSColor *ALPopoverBackgroundBorderColor;


#pragma mark -
@interface ALPopoverBackgroundView ()
@end


#pragma mark -
@implementation ALPopoverBackgroundView

+(void)initialize {
    ALPopoverBackgroundBorderColor = [NSColor colorWithCalibratedWhite:0.75f alpha:1.0f];
}

-(void)drawRect:(NSRect)dirtyRect {
    NSRect convertedBounds = [self convertRectToBacking:[self bounds]];
    NSRect insetBounds = NSInsetRect(convertedBounds, 0.5, 0.5);
    NSRect finalBounds = [self convertRectFromBacking:insetBounds];
    NSBezierPath *borderPath = [NSBezierPath bezierPathWithRoundedRect:finalBounds xRadius:kALPopoverBackgroundCornerRadius yRadius:kALPopoverBackgroundCornerRadius];
    
    [[NSColor whiteColor] setFill];
    [ALPopoverBackgroundBorderColor setStroke];
    [borderPath fill];
    [borderPath stroke];
}

@end
